package com.young.web.ec.config;

import java.net.UnknownHostException;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

import com.mongodb.MongoClient;
import com.young.web.ec.persistence.repository.MenuItemRepository;

@Configuration
@EnableMongoRepositories(basePackages = "com.young.web.ec.persistence.repository", includeFilters = @ComponentScan.Filter(value = {MenuItemRepository.class}, type = FilterType.ASSIGNABLE_TYPE))
public class MongoConfiguration {

	public @Bean MongoTemplate mongoTemplate(MongoClient mongo) throws UnknownHostException {
		return new MongoTemplate(mongo,"yummynoodle");
	}
	
	public @Bean MongoClient mongo() throws UnknownHostException {
		return new MongoClient("localhost");
	}
}
